import 'package:flutter/material.dart';

class ReachBottomLoad extends StatefulWidget {
  const ReachBottomLoad({ Key? key }) : super(key: key);

  @override
  _ReachBottomLoadState createState() => _ReachBottomLoadState();
}

class _ReachBottomLoadState extends State<ReachBottomLoad> {

  List<Widget> list=[];
  @override
  void initState() {
    super.initState();
    for(var i=0;i<10;i++){
      list.add(
        Center(child: Text('第${i+1}屏'),)
      );
    }

  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title:const Text('上拉加载')),
      body: PageView(
        scrollDirection: Axis.vertical,
        onPageChanged:(index){
          if(index==list.length-2){
            list.add(
              const Center(child:Text('上拉加载的屏'),)
            );
          }
        },
        children: list
      ),
    );
  }
}
